package test;

import com.itqf.dao.AccountDao;
import com.itqf.service.AccountService;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @Description:
 * @Company: 千锋互联
 * @Author: 李丽婷
 * @Date: 2020/9/29
 * @Time: 下午3:14
 */
public class SpringJDBC {

    @Test
    public   void  test(){
        ApplicationContext applicationContext = new
                ClassPathXmlApplicationContext("applicationContext.xml");

        AccountDao accountDao = (AccountDao) applicationContext.getBean("accountDao");

        System.out.println(accountDao.findById("1"));

    }

    @Test
    public   void  testTransfer() {
        ApplicationContext applicationContext = new
                ClassPathXmlApplicationContext("applicationContext-tx.xml");

        //配置事务后得到的是代理对象
        AccountService accountService = (AccountService) applicationContext.getBean("accountService");

        accountService.transfer("1","2",100);

    }

    }
